import { EOChild, fragment } from "./childrenBuilder";
import { ifChildren } from "./ifChildren";
import { mve } from "./util";



/**
 * 无缓存mvc
 * @param array 
 * @param fun 
 */
export function filterChildren<T, EO>(
	array: () => T[],
	fun: (me: mve.LifeModel, row: T, index: number) => EOChild<EO>
): EOChild<EO> {
	return ifChildren(function (me) {
		const vs: EOChild<EO>[] = []
		array().forEach(function (row, index) {
			const v = fun(me, row, index)
			vs.push(v)
		})
		return fragment({
			children: vs
		})
	})
}